package com.winshare.saleAssistant.domain.dto.req;

import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.hibernate.validator.constraints.Range;

import javax.validation.constraints.NotNull;

@ApiModel
public class ArticleModuleQueryDTO {

    @NotNull(message = "每页数量不能为空")
    @Range(min = 1, message = "每页数量必须大于或等于1")
    @ApiModelProperty(value = "每页数量，建议10-20")
    private Integer pageSize;

    @NotNull(message = "第几页 字段为能为空")
    @Range(min = 1, message = "页号至少从第1页开始")
    @ApiModelProperty(value = "第几页，从1开始")
    private Integer pageIndex;

    @JsonIgnore
    @ApiModelProperty(hidden = true)
    public Integer getOffsetIndex() {
        return pageSize * (pageIndex < 1 ? 0 : pageIndex-1);
    }

    public ArticleModuleQueryDTO() {
    }

    public Integer getPageSize() {
        return pageSize;
    }

    public void setPageSize(Integer pageSize) {
        this.pageSize = pageSize;
    }

    public Integer getPageIndex() {
        return pageIndex;
    }

    public void setPageIndex(Integer pageIndex) {
        this.pageIndex = pageIndex;
    }
}
